<template>
  <label class="m-checkbox" :for="label" :class="{disabled: disabled}">
    <input type="checkbox" 
      :id="label"
      :checked="value"
      :disabled="disabled"
      @change="onChange">
    <span class="check-btn"></span>
    <slot></slot>
  </label>
</template>

<script>
export default {
  props: {
    value: {
      type: Boolean,
      deufult: false
    },
    label: {
      type: [String, Number],
      default: ''
    },
    name: {
      type: String,
      deufult: null
    },
    disabled: {
      type: Boolean,
      default: false
    }
  },
  methods: {
    onChange(ev) {
      if (this.value) {
        this.$emit('input', false)
        this.$emit('on-change', false)
      } else {
        this.$emit('input', true)
        this.$emit('on-change', true)
      }
    }
  }
}
</script>

<style lang="scss" scoped>
  @import '../../scss/_checkbox.scss';
</style>